<template>
  <div class="recommended-products">
    <h1 class="d-title">{{ componentData[`title${capitalizeLang}`] }}</h1>
    <p class="sub-title">{{ componentData[`subTitle${capitalizeLang}`] }}</p>
    <div class="products">
      <div v-for="(item, index) in componentData.list" :key="index" class="pro-col" @click="toPage(item)">
        <div class="pro-item">
          <img :src="item.coverImage" alt="" />
          <p class="ft-bold">{{ item[`title${capitalizeLang}`] }}</p>
          <p class="ft-24 grey">{{ item[`subtitle${capitalizeLang}`] }}</p>
        </div>
      </div>
    </div>
    <div class="more" @click="toProduct">{{ $t('common.more') }} →</div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  props: {
    componentData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {}
  },
  computed: {
    ...mapGetters(['capitalizeLang']),
  },
  methods: {
    async toPage(item) {
      if (!item.url) {
        return
      }

      this.$router.push({
        path: '/solution',
        query: {
          id: item.url,
          type: item.classificationType,
        },
      })
    },
    toProduct() {
      this.$router.push({
        path: '/product',
      })
    },
  },
}
</script>

<style lang="less" scoped>
@import '~assets/var';

.recommended-products {
  position: relative;
  background-color: #fff;

  .d-title {
    font-size: 36px;
    font-weight: bold;
    color: #333;
    padding: 48px;
    text-align: center;
  }

  .sub-title {
    font-size: 24px;
    font-weight: 500;
    color: #888;
    padding-left: 24px;
  }

  .products {
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;

    .pro-col {
      margin-left: 24px;

      &:nth-last-child(1) {
        margin-right: 24px;
      }

      .pro-item {
        width: 316px;
        height: 400px;
        background: #f0f0f0;
        display: flex;
        align-items: center;
        flex-direction: column;
        text-align: center;
        padding-top: 16px;
        margin-bottom: 24px;
        font-size: 28px;

        img {
          max-width: 240px;
          max-height: 240px;
        }
      }
    }
  }

  .ft-24 {
    font-size: 22px;
  }

  .more {
    color: #0261bc;
    text-align: right;
    font-size: 26px;
    font-weight: bold;
    margin: 24px;
  }
}
</style>
